package com.lin.fengxiu.vo;

import com.lin.fengxiu.model.Category;
import lombok.Getter;
import lombok.Setter;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @ClassName CategoriesAllVO
 * @Description TODO
 * @Author wushaopei
 * @Date 2021/3/16 23:38
 * @Version 1.0
 */
@Setter
@Getter
public class CategoriesAllVO {

    private List<CategoryPureVO> roots;
    private List<CategoryPureVO> subs;

    /**
     * @Description 获取所有的category
     * @param map
     */
    public CategoriesAllVO(Map<Integer,List<Category>> map) {
        this.roots = map.get(1).stream()
            .map(CategoryPureVO::new)
            .collect(Collectors.toList());
        this.subs = map.get(2).stream()
                .map(CategoryPureVO::new)
                .collect(Collectors.toList());
    }
}
